package grape.attend.service.user.impl;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import grape.attend.service.classe.api.IClasseService;
import grape.attend.service.group.api.IGroupService;
import grape.attend.service.overtime.api.IOvertimeLegalService;
import grape.attend.service.overtime.api.IOvertimeRestService;
import grape.attend.service.overtime.api.IOvertimeService;
import grape.attend.service.overtime.api.IOvertimeWorkService;
import grape.attend.service.user.api.IUserClockDateService;
import grape.attend.service.user.api.IUserClockService;
import grape.attend.service.user.api.IUserOvertimeService;
import grape.attend.service.user.mapper.UserOvertimeMapper;
import grape.attend.service.user.po.UserClock;
import grape.attend.service.user.po.UserClockDate;
import grape.attend.service.user.po.UserOvertime;
import grape.attend.service.user.query.UserClockDateListQuery;
import grape.attend.service.user.query.UserClockListQuery;
import grape.attend.service.user.query.UserOvertimeListQuery;
import grape.base.rest.client.dict.DictClient;
import grape.base.rest.client.workcalendar.WorkCalendarClient;
import grape.common.service.common.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 用户加班表 服务实现类
 * </p>
 *
 * @author yangwei
 * @since 2020-05-18
 */
@Service
public class UserOvertimeServiceImpl extends BaseServiceImpl<UserOvertimeMapper, UserOvertime> implements IUserOvertimeService {


    @Override
    public List<UserOvertime> getByUserIdAndMonth(Long monthMs, String userId) {

        DateTime monthDate = DateUtil.date(monthMs);
        UserOvertimeListQuery userOvertimeListQuery = new UserOvertimeListQuery();

        userOvertimeListQuery.setClasseDateStart(DateUtil.beginOfMonth(monthDate).toDateStr());
        userOvertimeListQuery.setClasseDateEnd(DateUtil.endOfMonth(monthDate).toDateStr());
        userOvertimeListQuery.setPoQuery(new UserOvertime().setUserId(userId));

        return list(userOvertimeListQuery);

    }
}
